package com.recsmile.sgs.entity;

import com.recsmile.sgs.core.Player;
import com.recsmile.sgs.operation.Operation;
import com.recsmile.sgs.ui.components.GamePanelGui;

import java.util.List;
import java.util.Stack;

/**
 * Created by Administrator on 2016/8/26.
 */
public class GamePanel {

    private final Stack<Operation> currentOperations;

    public GamePanel(Player player, List<Player> players) {
        currentOperations = new Stack<>();
        this.gamePanelGui = new GamePanelGui(player,this);
        for (Player p : players){
            if(p.getId() !=  player.getId()){
                gamePanelGui.addPlayer(p);
            }
        }
    }


    private GamePanelGui gamePanelGui;

    //@Override
    public synchronized void pushOperation(Operation operation, Activatable source) {
        if (source != null) {
            source.setActivated(true);
        }
        operation.onActivated(this, source);
        currentOperations.push(operation);
    }

    //@Override
    public synchronized void popOperation() {
        currentOperations.pop();
    }

    //@Override
    public synchronized Operation getCurrentOperation() {
        return currentOperations.peek();
    }

    public GamePanelGui getGamePanelGui() {
        return gamePanelGui;
    }
}
